<?php

/**
 * @package NUKEVIET
 * @subpackage WikiDic Service
 * @author Long Nguyen (long@wpvampire.com)
 * @copyright 2011
 * @since 3.2
 */

if ( ! defined( 'NV_IS_FILE_MODULES' ) ) die( 'Stop!!!' );

$sql_drop_module = array();

$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $module_data . "_apps;";
$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $module_data . "_definitions;";
$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $module_data . "_dics;";
$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $module_data . "_feedbacks;";
$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $module_data . "_terms;";

$sql_create_module = $sql_drop_module;

$sql_create_module[] = "CREATE TABLE `" . $db_config['prefix'] . "_" . $module_data . "_apps` (
	  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
	  `user_id` int(11) unsigned NOT NULL,
	  `name` varchar(255) NOT NULL DEFAULT '',
	  `api_key` varchar(255) NOT NULL DEFAULT '',
	  `secret_key` varchar(255) NOT NULL DEFAULT '',
	  `status` tinyint(4) NOT NULL DEFAULT '0',
	  `options` text,
	  PRIMARY KEY (`id`)
	) ENGINE=MyISAM";

$sql_create_module[] = "CREATE TABLE `" . $db_config['prefix'] . "_" . $module_data . "_definitions` (
	  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
	  `term_id` int(11) NOT NULL,
	  `definition` text,
	  `status` tinyint(11) NOT NULL DEFAULT '0',
	  `revision` int(11) DEFAULT NULL,
	  `created` datetime DEFAULT NULL,
	  `modified` datetime DEFAULT NULL,
	  `log` text,
	  PRIMARY KEY (`id`)
	) ENGINE=MyISAM";
	
$sql_create_module[] = "CREATE TABLE `" . $db_config['prefix'] . "_" . $module_data . "_dics` (
	  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
	  `name` varchar(255) NOT NULL DEFAULT '',
	  `description` text,
	  PRIMARY KEY (`id`)
	) ENGINE=MyISAM";
	
$sql_create_module[] = "CREATE TABLE `" . $db_config['prefix'] . "_" . $module_data . "_feedbacks` (
	  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
	  `definition_id` int(11) NOT NULL,
	  `app_id` int(11) NOT NULL,
	  `user_id` int(11) NOT NULL,
	  `message` text NOT NULL,
	  `rating` tinyint(4) NOT NULL DEFAULT '0',
	  `created` datetime DEFAULT NULL,
	  `modified` datetime DEFAULT NULL,
	  PRIMARY KEY (`id`)
	) ENGINE=MyISAM";
	
$sql_create_module[] = "CREATE TABLE `" . $db_config['prefix'] . "_" . $module_data . "_terms` (
	  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
	  `dic_id` int(11) NOT NULL,
	  `term` varchar(255) NOT NULL DEFAULT '',
	  `status` tinyint(4) NOT NULL DEFAULT '0',
	  `revision` int(11) DEFAULT NULL,
	  `created` datetime DEFAULT NULL,
	  `modified` datetime DEFAULT NULL,
	  `log` text,
	  PRIMARY KEY (`id`),
	  UNIQUE KEY `term` (`term`)
	) ENGINE=MyISAM";

?>